Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New staging #742

Merged
merged 62 commits into from
Dec 19, 2024
Merged

New staging #742

merged 62 commits into from
Dec 19, 2024

Conversation

w23
Copy link
Owner

@w23 w23 commented May 30, 2024

  • image staging
    • some images are corrupted
    • [ ] invert vk_image upload api #745 -- postponed until next time we'd need to touch images; current code works good enough for now.
    • use combuf auto barriers everywhere where it makes sense
  • corrupted geometry in playdemo ...
  • buffer staging
  • RT-trad dynamic toggle
    • push-pull staging boundary
  • frame dependency tracking: automatically free/flip buffers when frame using them is done
  • replace ALL barriers with combuf ones
    • buffers in rtx/resources
    • images
      • track images sync state inline where possible
    • find other uses
  • improve staging
    • track staging users explicitly
      • per-user stats: sizes, allocations, etc
      • push remaining data for stale users
    • use ring buffer directly, track frame boundaries externally in fctl
  • crash in buildBlases():
    1. load map with rt disabled
    2. change to another map
    3. enable rt
    4. 💥
  • suboptimal barrier, see comment New staging #742 (comment)
  • simplify creating and building TLAS
  • Run rendering tests

w23 added 4 commits May 30, 2024 11:56
Also add dynamic array (not used in this commit)
This is untested PoC quality. Staging regions are not tracked properly
yet. Image upload commit is also done at a weird place.
fixes building on windows
handles canceling holes

still, corrupts some textures for some reason
Prior to this change `R_VkImageClear()` functtion was causing SYNC-HAZARD-WRITE-AFTER-READ error, thinking that clearing `[dest]` image is not synchronized with blit during the previous frame. However, there's an explicit semaphore sync with the previous frame, and as such it seems this validation complaint is baseless.

I'd make a simple repro and submit it to validation repo, but who am i kidding, i have like 10 minutes left to do anything today, and i likely won't be able to get back to this in several days.
w23 added 8 commits November 26, 2024 17:21
also add some notes about clangdb and staging problems
Apparently now it is possible to handle emissive brush surfaces at the same time as generating geometry. No second pass for emissive extraction is needed.

This allows skipping extra `R_VkStagingFlushSync()`.

Not all flush-sync usages are removed, though.
@w23 w23 mentioned this pull request Dec 10, 2024
4 tasks
w23 added 16 commits December 10, 2024 08:32
It's an incomplete intermediary change. This commit doesn't work.

It compiles tho.

Changes:
- Move buffer staging tracking to vk_buffer
- Sketch automatic buffer barriers tied to vk_combuf
- Remove all combuf handling from staging. That was just gross.

Breaks:
- Everything.
- RT AS building is commented out for now
it render quite a few traditional frames
but then fails with cross-cmdbuf sync validation errors
- print out vkQueueSubmit with its semaphores
- print out buffer barriers
- print out when buffer copy submission happens
- print various ref_vk initialization stages
Validation was complaining about odd SYNC-HAZARD-WRITE-AFTER-READ lack of buffer barrier at the very beginning of a frame, while I thought that command buffers are properly serialized by semaphores.
Turns out, `VkSubmitInfo::pWaitDstStageMask` should accompany each wait semaphore with its corresponding stage.
Properly setting TOP_OF_PIPE for the wait semaphore of a previous submission fixes the complaint.
This is likely no the right way to do this. Address this when focusing on correct gamma overall for traditional renderer. Currently this is here just to make it have some non-zero values early.
Previous 20.04 doesn't have the latest Vulkan SDK.
Also print deps script commands verbosely for easier CI debugging.
w23 added 19 commits December 11, 2024 23:42
Allows to remove a small pile of manual barriers yay.
It compiles, but it's broken and doesn't pass validation yet. Resource part doesn't collect barriers correctly somehow, needs debugging.
Now it works!
Needs a bit of a cleanup, though.
This adds explicit staging user tracking, which allows:
- tracking whether there are any unclaimed items, and pushing them (or ignoring, if the user decides so, for transient stuff)
- having more granular stats for staging, i.e. which buffer/subsystem used staging in this frame, and how much (not implemented yet)

This commit also changes staging from using flip buffer to just ring buffer allocator.
`staging.<USER>.size` and `staging.<USER>.allocs` r_speeds metrics are now available for every staging user.
Move draw_instance into ray_accel module. Then, when building TLAS, go through all instances, and check whether their blases need to be (re)built. Enqueue those who need to be rebuilt before building TLAS.

Fixes crashing when doing changelevel w/o rt, and then enabling rt.
…rriers

Group by access/stage, not by src/dst. Makes logs a bit more readable.
Previously we forced src image layout to be UNDEFINED if the image was
to be written into. This lead to RADV driver to completely clear our so
painfully constructed ray traced frame.

The correct layout transition should probably be something like this: if
we're not to _read_ from image contents, only then we can be sure that
its contents are not needed anymore, and can be discarded by settind the
src layout to UNDEFINED.
@w23
Copy link
Owner Author

w23 commented Dec 17, 2024

1039 [2024:12:17|13:37:15] Warning: vk/dbg: Validation Warning: [ BestPractices-ImageBarrierAccessLayout ] Object 0: handle = 0x29a2fa0000001010, name = swapchain image[0], type = VK_OBJECT_TYPE_IMAGE; | MessageID      = 0xf35d019f | vkCmdPipelineBarrier2(): pDependencyInfo->pImageMemoryBarriers[0] image is VkImage 0x29a2fa0000001010[swapchain image[0]] and accessMask is VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT|VK_ACCESS_2_CO     LOR_ATTACHMENT_WRITE_BIT|VK_ACCESS_2_MEMORY_READ_BIT, but for layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR expected accessMask are VkAccessFlags2(0).

w23 added 6 commits December 17, 2024 23:41
This makes c0a0d toxic pool emissive again, but it still doesn't make all known toxic water objects emissive.
This was a bug in validation layers, it's been fixed back in 2021.
Swapchain framebuffer image being in VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout has zero access flags, and is probably synced with bottom-of-pipe stage.

At least this does please validation layers.
@w23 w23 changed the title [WIP] New staging New staging Dec 19, 2024
@w23 w23 marked this pull request as ready for review December 19, 2024 00:48
@w23 w23 merged commit 300658c into stream-E376-resman Dec 19, 2024
9 checks passed
@w23 w23 deleted the stream-E379-staging branch December 19, 2024 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant